/**
 * Created by dale on 2017/8/23.
 */
$(document).ready(function () {


    var form = new xhForm($('#xh_form'));
    form.parse();
    $(".form-date").datetimepicker({format: 'yyyy-mm-dd', language: 'zh-CN', minView: "month", autoclose: true});

    var id=addressUri.getParam('id');
    var name=addressUri.getParam('name');

    $('[name="iCUId"]').val(id);
    $('[name="sSchoolName"]').val(unescape(name));
    $('[name$="tStartTime"]').val(new Date().format('yyyy-MM-dd'));

    $('#bt_modal_confirm',parent.document).click(function () {
        $.ajax({
            url:modelUrl+'plan/savePlan',
            data:$('#xh_form').serialize(),
            type:'POST',
            dataType:'json',
            success:function (data) {
                $('#bt_modal_confirm',parent.document).addClass('disabled');
                if (data['code'] == 200) {
                    window.top.xhTop.createNewTab('流程计划',baseUrl+'bpm/plan/planList?openId='+data['iBPPId']+'',true);
                    window.top.xhTop.closeModal();
                } else {
                    window.top.xhTop.showError('错误', data['msg']);
                }
            },
            error:function (data) {
                console.log(data);
            }
        });
    });

    modalBind.bindClick();
    
});
